home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj0987.arc / MISS.C < prev    next >
Text File  |  1987-07-02  |  2KB  |  78 lines

  1. /*
  2.  * MISS --PC Tech Journal Laser Printer Miscellanous Tests
  3.  *
  4.  * Version 1.0
  5.  *
  6.  * Copyright (c) 1987, Ziff Communications Company
  7.  * Program by: Rainer McCown and Bob Smith
  8.  * Common Routines for C programs.
  9.  */
  10.  
  11. #include "io.h"
  12. #include "dos.h"
  13. #include "string.h"
  14. #include "fcntl.h"
  15.  
  16. #define STD_OUT 1
  17.  
  18. /****************************** SNDL *******************************/
  19. /* Use this routine when the string-to-be-printed
  20.    contains embedded binary zeros (which can confuse
  21.    the STRLEN function used in SND). */
  22.  
  23. void sndl(sray, len)
  24.  
  25. char sray[];
  26. int len;
  27.  
  28. {
  29.  if (len != write(STD_OUT, sray, len)) printf("%s\r\n", sray);
  30. }
  31.  
  32. /****************************** SND ********************************/
  33. /* Use this routine to send a string
  34.    to the standard printer */
  35.  
  36. void snd(sray)
  37.  
  38. char sray[];
  39.  
  40. {
  41.  sndl(sray, strlen(sray));
  42. }
  43.  
  44. /*************************** SETBINARY *****************************/
  45. /* Change a file handle to binary mode to avoid
  46.    converting LFs to CR,LF and to avoid
  47.    stopping on EOFs */
  48.  
  49. void setbinary(fh)
  50.  
  51. int fh;
  52.  
  53. {
  54.  union REGS inregs;
  55.  
  56.  /* Change to binary mode via SETMODE
  57.     to avoid converting LF to CR,LF  */
  58.  
  59.  setmode(fh, O_BINARY);
  60.  
  61.  
  62.  /* Change to binary mode via IOCTL
  63.     to avoid stopping on EOF  */
  64.  
  65.  inregs.x.ax = 0x4400;        /* Fn code to get device information */
  66.  inregs.x.bx = fh;        /* For the file handle */
  67.  intdos(&inregs, &inregs);    /* Return device info in DX */
  68.  
  69.  if(inregs.x.dx & 0x0080)    /* If it's a device, ... */
  70.    {
  71.     inregs.h.dh = 0;        /* Ensure zero */
  72.     inregs.x.dx |= 0x0020;    /* Turn on binary mode bit */
  73.     inregs.x.ax = 0x4401;    /* Fn code to set device information */
  74.     intdos(&inregs, &inregs);    /* Set device info from DX */
  75.    }
  76. }
  77.  
  78.